package mop.exception;

import java.util.Map;
import mop.model.task.TaskInterface;



/**
 * Exception class to be thrown when business rule 2 is violated in the third alternate flow
 * 
 * @author	 MOP Team 7
 */

public class RecursiveBusinessRule2Exception extends Throwable
{


	/**
	 * Initializes an RecursiveBusinessRule2Exception with the problematic map
	 * 
	 * @param map The problematic tasks
	 *  
	 * @post this.map == map
	 */
	public RecursiveBusinessRule2Exception(Map<TaskInterface,String> map)
	{
		this.map =  map;
	}
	
	
	/**
	 * Return a error message that can be used by the GUI
	 * @return An error message describing the incorrect name
	 */
	public String toString()
	{
		StringBuffer sb = new StringBuffer();
		sb.append("Business Rule 2 has been violated!\b\n");
		sb.append("This rule states that if a task depends on a task that is failed, then that task should also be failed.\n");
		sb.append("If a task depends on a task that is unfinished, then that task should be failed or unfinished.");
	
		return sb.toString();
	}
		 
	 /**
	  * Returns the map
	  * @return this.map
	  */
	 public Map<TaskInterface,String> getMap()
	 {
		 return this.map;
	 }
	
	/**
	 * Weird java demand
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * The map with the problems in it
	 */
	private Map<TaskInterface,String> map;

}
